/*
 * @Author: your name
 * @Date: 2021-08-26 12:46:30
 * @LastEditTime: 2022-05-31 09:31:23
 * @LastEditors: hq
 * @Description: In User Settings Edit
 * @FilePath: \money-app\utils\signature.js
 */
/* 
 *签名字符：
 *    date=2021-06-25 17:53:01&merchant=1000080&user=张三&user_id=100
 *    &key=48YUwdNjbYYTAu76s5U7D78H6KJpHGRT
 *   
 * @key:前后端协商的key   48YUwdNjbYYTAu76s5U7D78H6KJpHGRT
 */
import md5 from "js-md5";

export default function sort_ascii(obj) {
    //排序
    let keysArr = Object.keys(obj).sort();
    let sortObj = {};
    for (let i in keysArr) {
        sortObj[keysArr[i]] = obj[keysArr[i]];
    }
    // return sortObj;
    //拼接
    let str = '';
    for (let key in sortObj) {
        if (str === '') {
            str = key + sortObj[key];
        } else {
            str = str + key + sortObj[key];
        }
    }
    //key123page1sortdesctimestamp1625470495
    // str = str + '&key=48YUwdNjbYYTAu76s5U7D78H6KJpHGRT';
    return md5(str + 'insist').toUpperCase();
}